<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据库管理</title>
<script type="text/javascript" src="/j-tool/jquery.js"></script>
<link href='/public/css/admins.css' rel='stylesheet' type='text/css'/>
<body>
	<div class='bread'>账号管理</div>
	<div class="manageBox">
		<div class="formBox">
			<form method="post" name="psource" action="" onsubmit="return false;"> 
				<table class="searchBox">
					<tr>
						<td>用户名：</td><td><input type="text" name="uname" class="input-text"/></td>
					</tr>
					<tr>
						<td>电子邮件：</td><td><input type="text" name="email" class="input-text"/></td>
					</tr>
					<tr>
						<td>状态：</td><td><input type="text" name="level" class="input-text"/></td>
					</tr>
					<tr>
						<td></td><td><input type="submit" value="查询" class="butt" onclick="usearch();"/>&nbsp;&nbsp;&nbsp;&nbsp;标记为：&nbsp;&nbsp;<a href="JavaScript:;" onclick="dealWith('update')">修改</a>&nbsp;|&nbsp;<a href="JavaScript:;" onclick="dealWith('forbid')">禁用</a>&nbsp;|&nbsp;<a href="JavaScript:;" onclick="dealWith('open')">启用</a>&nbsp;|&nbsp;<a href="JavaScript:;" onclick="dealWith('dele')">删除</a></td>
					</tr>
				</table>
			</form>
			<div class="clear"></div>
		</div>
		<div class="infolist">
			<ul><li class="w5"><a href="javascript:;" onclick="choseAll();">全选</a></li><li class="w10">用户名</li><li class="w15">电子邮箱</li><li class="w10">等级</li><li class="w15">上次登录时间</li><li>状态</li></ul>
			<div class="result">
				<!--{foreach from=$list item=val}-->
				<ul>
					<li class="w5"><input type="checkbox" name="chose[<!--{$val.id}-->]" value="<!--{$val.id}-->"/></li>
					<li class="w10"><!--{$val.nickname}--></li>
					<li class="w15"><!--{$val.email}--></li>
					<li class="w10"><!--{if $val.level eq 0}-->管理员<!--{else}-->会员<!--{/if}--></li>
					<li class="w15"><!--{$val.logintime}--></li>
					<li>
						<!--{if $val.status eq 0}-->
						<font color='green'>在线</font>
						<!--{elseif $val.status eq 1 }-->
						<font color='gray'>离线</font>
						<!--{elseif $val.status eq 2}-->
						<font color='red'>已禁用</font>
						<!--{/if}-->
					</li>
				</ul>
				<!--{/foreach}-->
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="/j-tool/admins.js"></script>
<script type="text/javascript">
	function dealWith(does)
	{	
		if($("input:checked").serialize())
		{
			$.ajax({
			   type: "POST",
			   url: "admins_ajax.php",
			   data: 'action=user_'+does+'&'+$("input:checked").serialize(),
			   success: function(msg){
					msg == 'OK'?location.reload():alert(msg);				
			   }
			});
		}else{
			alert('请选择操作的对象');
		}
	}

	function usearch()
	{
		$.ajax({
		   type: "POST",
		   url: "admins_ajax.php",
		   data: 'action=users&'+$("form").serialize(),
		   success: function(msg){
				if(msg !='null')
				{
					var data = $.parseJSON(msg),html='';
					for(var i=0;i<data.length;i++)
					{
						html += "<ul><li class='w5'><input type='checkbox' name='chose["+data[i].id+"]' value='"+data[i].id+"'/></li><li class='w10'>"+data[i].nickname+"</li><li class='w15'>"+data[i].email+"</li><li class='w10'>"+(data[i].level==0?"管理员":"会员")+"</li><li class='w15'>"+data[i].logintime+"</li><li>"+(data[i].status==0?"<font color=green>在线</font>":data[i].status==1?"<font color=gray>离线</font>":"<font color=red>已禁用</font>")+"</li></ul>"
					}
					$('.result').html(html);
				}else{
					alert('没有找到相关数据');
				}			
		   }
		});
	}
</script>
</html>